home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 36 / testdis6.zip / TESTDIS6.ASM < prev    next >
Assembly Source File  |  1990-11-21  |  16KB  |  378 lines

  1. ;TestDis6.ASM  Exe program to load a font into the VGA adapter by
  2. ;using the VGA registers, thus by passing int 10, and DESQview.
  3. ;(Which means you can use this program to run DESQview with your
  4. ;favorite font.) Of course you need a VGA adapter to use this program.
  5. ;Also I make a call to a DOS 3.0+ function, but that can be changed
  6. ;to allow you to run this with a earlier DOS version.
  7. ;
  8. ;Note: switching video modes still will blow out the font. The advantage
  9. ;here is that normally DESQview captures int 10 and stores the font. Then
  10. ;you can only see it in the one window. This method changes the font GLOBALLY.
  11. ;With the provided PIF it loads the font and exits, freeing the ram.
  12. ;
  13. ;Syntax:  Testdis6  fontfile.fnt
  14. ;
  15. ;   ---By Christopher J. Vaisvil 11/21/90
  16. ;
  17. ;If you like, use any or all of this code.
  18. ;(I would like to be mentioned, just so I know you actually used
  19. ;the code...it would be neat to see someone do so!)
  20. ;
  21. ;This code and program are free, and your use of them frees _me_ 
  22. ;from any liability arising from the use or lack of use of either.
  23. ;
  24. ;This is free because I haven't paided as many shareware fees as I 
  25. ;would like, so I'm giving something back to the BBS world.
  26. ;Thanks to all of the great programmers out there!!
  27. ;
  28. ;MASM 5.1 used to write this program.
  29. ;I know the code could have been written much, much more efficently.
  30. ;However, I'm still learning and am happy the bugger don't lock up my
  31. ;machine! If you have any hints/comments, try the C-ASM national network.
  32. ;I've included a sample DV PIF file and a couple of fonts to get you
  33. ;started. 
  34. ;
  35. ;And now for the code....
  36. ;
  37. PushRegs    MACRO
  38.             push    ax
  39.             push    bx
  40.             push    cx
  41.             push    dx
  42.             push    ds
  43.             push    es
  44.             push    di
  45.             push    si
  46.             push    ss
  47.             push    sp
  48.             ENDM
  49. ;----------------------------------------------------------
  50. PopRegs     MACRO
  51.             pop     sp
  52.             pop     ss
  53.             pop     si
  54.             pop     di
  55.             pop     es
  56.             pop     ds
  57.             pop     dx
  58.             pop     cx
  59.             pop     bx
  60.             pop     ax
  61.             ENDM
  62. ;----------------------------------------------------------
  63.  
  64. DOSSEG
  65. .MODEL LARGE            ;Much better safe than sorry....
  66. .STACK 1000h            ;so I waste some ram.
  67. .DATA
  68. savepsp     DW  0000h                   ;store the program PSP
  69. Seqparms1   DW  0100h                   ;sync reset
  70.             DW  0402h                   ;CPU writes to map 2
  71.             DW  0704h                   ;sequential addressing
  72.             DW  0300h                   ;clear sync reset
  73. GCParms1    DW  0204h                   ;map 2 for CPU reads
  74.             DW  0005h                   ;disable even-odd addrs'ing
  75.             DW  0006h                   ;map starts at A000h
  76. Seqparms2   DW  0100h                   ;sync reset
  77.             DW  0302h                   ;CPU write to maps 0 and 2
  78.             DW  0304h                   ;odd-even addr'ing
  79.             DW  0300h                   ;clear sync reset
  80. GCparms2    DW  0004h                   ;select map 0 for CPU reads
  81.             DW  1005h                   ;enable even-odd addr'ing
  82.             DW  0E06h                   ;map starts @ B800:0000h
  83. font        DB  4096d   DUP(?)          ;Array for Font Table
  84. lfont       EQU $ - font                ;length of table
  85. points      DW  0000                    ;bytes per character
  86. rowsnow     DB  00                      ;character rows on screen - 1
  87. fontseg     DW  0000                    ;ROM font segment
  88. fontoff     DW  0000                    ;ROM font offset
  89. bytesread   DW  0000
  90. crlf        DW  13,10
  91. openmsg     DB  '*** Open Error ***'
  92. Showmsg     DB  'Thanks for Using Me!'
  93. row         DW  0000
  94. Column      DW  0000
  95. filename    DB  "              "
  96. parameters  DB  127d DUP(" ")
  97. paraptr     DW  0000
  98. error       DB  "DISK IO ERROR",13,10
  99. lerror      EQU $ - error
  100. errortype   DB  "...I'm confused!",13,10
  101. lerrortype  EQU $ - errortype
  102. handle      DW  0000
  103. dishan      DB  "ab"
  104. ldishan     EQU $ - dishan
  105. message     DB  "The DickensSoft VGA Font File Loader ",13,10
  106. lmessage    EQU $ - message
  107. message2    DB  " is the file handle.",13,10
  108. lmessage2   EQU $ - message2
  109. secptr      DW  0000
  110. disptr      DW  0000
  111. Error_status DW 0000
  112.  
  113. .CODE
  114. Start:
  115.             mov     ax,@DATA            ;initalize 
  116.             mov     ds,ax               ;the data segment
  117.             call    Get_PSP_Addrs       ;Using procedures
  118.             call    Command_Line        ;sure cleans things
  119.             call    e10open             ;up don't it?
  120.             call    Read_Font_File      ;See the routines
  121.             call    Set_Text            ;for the details.
  122.             call    Get_VGA_Info
  123.             call    Show_Logo
  124.             call    OpenCharMap
  125.             call    Fill_Def 
  126.             call    CloseCharMap
  127.  
  128. byebye:     mov     ax,4C00h            ;go back to DOS
  129.             int     21h
  130. ;----------------------------------------------------------
  131. Command_Line Proc near
  132.             PushRegs
  133.             mov     bx,savepsp          ;get PSP addrs
  134.             mov     es,bx               ;set it up
  135.             mov     bx,0                ;make sure bx is zero
  136.             mov     bl,es:[80h]         ;grab the #of bytes in param list
  137.             cmp     bx,0                ;did we get parameters?
  138.             je      Bad_Parameter       ;no, exit
  139.  
  140.             mov     cx,bx               ;yes, get how long the list is
  141.             inc     cx                  ;grab 0dh also
  142.             mov     bx,81h              ;set up ptr into param list
  143.             mov     paraptr,00          ;set up vari ptr
  144. getparam:   
  145.             mov     ah,BYTE PTR es:[bx] ;get char from list
  146.             cmp     ah,20h              ;space?
  147.             je      bypass_byte         ;skip it
  148.             mov     di,OFFSET filename  ;point to variable
  149.             add     di,paraptr          ;add ptr to ptr
  150.             cmp     ah,0dh              ;cr?
  151.             jne     go_on               ;nope, bypass
  152.             mov     ah,00               ;zero it for ASCIIZ
  153. go_on:      
  154.             mov     [di],ah             ;put it into filename, byte-wise
  155.             add     paraptr,1
  156. bypass_byte:
  157.             add     bx,1                ;move ptr to next byte
  158.             loop    getparam            ;loop till done
  159.             PopRegs
  160.             ret                         ;run the main body
  161. Bad_Parameter:
  162.             PopRegs
  163.             call    x10err              ;display error
  164.             mov     ax,4C00h            ;go back to DOS
  165.             int     21h
  166.             ret
  167. Command_Line endp
  168.  
  169. ;----------------------------------------------------------
  170. Get_PSP_Addrs Proc near    ;get the command line addrs (DOS 3.0+)
  171.             push    ax                  ;save ax
  172.             push    bx                  ;save bx
  173.             mov     ax,6200h            ;get PSP addrs (DOS 3.0+ only)
  174.             int     21h                 ;call DOS
  175.             mov     savepsp,bx          ;grab the PSP addrs
  176.             pop     bx                  ;restore
  177.             pop     ax                  ;registers
  178.             ret
  179. Get_PSP_Addrs   ENDP
  180. ;----------------------------------------------------------
  181. Set_Text Proc Near          ;set 80*25 text mode
  182.             push    ax                  ;save AX
  183.             mov     ax,0003h            ;req func 0, mode 3
  184.             int     10h                 ;have BIOS do it
  185.             pop     ax                  ;restore AX
  186.             ret
  187. Set_Text    EndP
  188. ;----------------------------------------------------------
  189. OpenCharMap Proc Near
  190.             PushRegs                    ;push all regs
  191.             mov     dx,03c4h            ;sequencer port addrs
  192.             mov     si,offset DGROUP:Seqparms1
  193.             mov     cx,4
  194. OCM1:
  195.             lodsw                       ;mov word to ax
  196.             out     dx,ax               ;shove to port
  197.             loop    OCM1                ;do cx times
  198.             mov     dl,00ceh            ;Graphics controller addrs
  199.             mov     si,offset DGROUP:GCparms1
  200.             mov     cx,3
  201. OCM2:
  202.             lodsw                       ;mov word to ax
  203.             out     dx,ax               ;shove to port
  204.             loop    OCM2                ;do cx times
  205.             PopRegs
  206.             ret
  207. OpenCharMap EndP
  208. ;----------------------------------------------------------
  209. CloseCharMap Proc Near
  210.             PushRegs                    ;push all regs
  211.             mov     dx,03c4h            ;sequencer port addrs
  212.             mov     si,offset DGROUP:Seqparms2
  213.             mov     cx,4
  214. CCM1:
  215.             lodsw                       ;mov word to ax
  216.             out     dx,ax               ;shove to port
  217.             loop    CCM1                ;do cx times
  218.             mov     dl,00ceh            ;Graphics controller addrs
  219.             mov     si,offset DGROUP:GCparms2
  220.             mov     cx,3
  221. CCM2:
  222.             lodsw                       ;mov word to ax
  223.             out     dx,ax               ;shove to port
  224.             loop    CCM2                ;do cx times
  225.             mov     ah,0fh              ;get video mode
  226.             int     10h                 ;ask bios to do it
  227.             cmp     al,7                ;is it mono?
  228.             jne     CCM3                ;if not jump...
  229.             mov     ax,0806h            ;must be mono
  230.             out     dx,ax               ;set addrs to b000h
  231. CCM3:
  232.             ;B800h (color) already set in GCparms2
  233.             PopRegs
  234.             ret
  235. CloseCharMap EndP
  236. ;----------------------------------------------------------
  237. Fill_Def Proc near
  238.             PushRegs
  239.             mov     cx,4096d            ;number of char definitions
  240.             mov     bx,0                ;start at zero
  241.             mov     ax,0a000h           ;char def addrs
  242.             mov     es,ax               ;set it up
  243.             mov     ax,WORD PTR font[bx];grab first byte
  244.             mov     dx,bx               ;set up def tbl ptr
  245.             mov     disptr,0            ;set up counter
  246. Fill_def_1:
  247.             xchg    bx,dx               ;make MASM happy....
  248.             mov     es:[bx],ax          ;char def to video ram
  249.             xchg    bx,dx               ;get old value
  250.             inc     bx                  ;need to increment the ptrs 
  251.             inc     dx                  ;as we grab words
  252.             inc     disptr              ;increase scanline counter
  253.             cmp     disptr,16d          ;done a character?
  254.             je      adjust
  255. returns:
  256.             mov     al,BYTE PTR font[bx];get next char def
  257.             loop    fill_def_1          ;do next char definition
  258.             PopRegs
  259.             ret
  260. adjust:
  261.             mov     disptr,0            ;zero counter
  262.             add     dx,16d              ;jump 16 scan lines in definition
  263.             jmp     returns             ;go back to work
  264.             PopRegs
  265.             ret
  266. fill_def   endp
  267. ;---------------Disk IO error routine----------------------
  268. x10err  proc    near
  269.         mov     ax,0600h            ;clear screen
  270.         call    q10scr              ;clear screen
  271.         call    q20curs             ;set cursor
  272.             mov     bx,1            ;Show who we are..
  273.             mov     cx,lmessage
  274.             mov     dx,OFFSET message
  275.             mov     ax,4000h
  276.             int     21h
  277.         mov     dx,OFFSET openmsg
  278.         mov     ah,40h              ;DX contains addrs, set on call
  279.         mov     bx,01               ;screen IO handle
  280.         mov     cx,20               ;length of msg
  281.         int     21h                 ;call DOS to display
  282.         ret
  283. x10err  endp
  284. ;---------------Scroll Screen------------------------------
  285. q10scr  proc    near                ;AX set on entry
  286.         mov     bh,1eh              ;set color
  287.         mov     cx,0000             ;
  288.         mov     dx,184fh            ;request scroll
  289.         int     10h                 ;call video bios
  290.         ret
  291. q10scr  endp
  292. ;---------------Set Cursor---------------------------------
  293. q20curs proc    near
  294.         mov     ah,02               ;request set
  295.         mov     bh,00               ;cursor
  296.         mov     dh,BYTE PTR row     ;row
  297.         mov     dl,BYTE PTR disptr  ;column
  298.         int     10h                 ;call video bios
  299.         ret
  300. q20curs endp
  301. ;---------------read sector--------------------------------
  302. r10read     proc    near
  303.             pushregs
  304.             mov     ax,3f00h        ;request read
  305.             mov     bx,handle       ;device
  306.             mov     cx,lfont        ;length of buffer
  307.             mov     dx,OFFSET font  ;addrs of buffer
  308.             int     21h             ;call DOS
  309.             mov     bytesread,ax    ;get # bytes read
  310.             popregs
  311.             ret
  312. r10read     endp
  313. ;---------------open file----------------------------------
  314. e10open proc    near
  315.         mov     ah,3dh              ;request open
  316.         mov     al,00               ;read only
  317.         mov     dx,OFFSET filename
  318.         int     21h                 ;
  319.         jc      e20                 ;Error?
  320.         mov     handle,ax           ;no - save handle
  321.         ret
  322. e20:
  323.         mov     bytesread,01        ;yes --
  324.         mov     dx,OFFSET openmsg   ;error message
  325.         call    x10err
  326.         ret
  327. e10open endp
  328. ;----------------------------------------------------------
  329. Get_VGA_Info Proc Near          ;get VGA info. Not much of its used now...
  330.             PushRegs
  331.             mov     ah,11h              ;BIOS int 11h
  332.             mov     al,30h              ;Function 30h
  333.             mov     bh,06h              ;get VGA 8x16 font in ROM
  334.             int     10h                 ;tell video BIOS to do it
  335.             mov     ax,es               ;get font segment
  336.             mov     fontseg,ax          ;store it
  337.             mov     ax,bp               ;get font offset
  338.             mov     fontoff,ax          ;store it
  339.             mov     al,dl               ;get char rows
  340.             mov     rowsnow,al          ;store it
  341.             mov     ax,cx               ;get bytes per char
  342.             mov     points,ax           ;store it
  343.             PopRegs
  344.             Ret
  345. Get_VGA_Info endp
  346. ;----------------------------------------------------------
  347. Read_Font_File Proc Near        ;call a routine to read in the specified font
  348.             PushRegs
  349. Load_The_Font:
  350.             call    r10read             ;get the font into ram
  351. Loaded:
  352.             PopRegs                     ;we are done, let's return
  353.             ret
  354. Read_Font_File endp
  355. ;----------------------------------------------------------
  356. Show_Logo proc    near              ;show who wrote me
  357.         mov     ax,0600h            ;clear screen
  358.         call    q10scr              ;clear screen
  359.         call    q20curs             ;set cursor
  360.             mov     bx,1            ;Show who we are..
  361.             mov     cx,lmessage
  362.             mov     dx,OFFSET message
  363.             mov     ax,4000h
  364.             int     21h
  365.         mov     dx,OFFSET Showmsg
  366.         mov     ah,40h              ;DX contains addrs, set on call
  367.         mov     bx,01               ;screen IO handle
  368.         mov     cx,22               ;length of msg
  369.         int     21h                 ;call DOS to display
  370.         ret
  371. Show_Logo  endp
  372. ;----------------------------------------------------------
  373.  
  374. End     Start
  375. ;---------------------------------------------------------------------
  376.  
  377. 
  378.